<?php defined('SYSPATH') or die('No direct script access.');

    /**目的地
     * Class Controller_Pc_Api_V2_Destination
     */
    class Controller_Pc_Api_V2_Destination extends Controller_Pc_Api_v2_Base
    {
        private $result;
        /**
         * 验证类
         * @var Request_Api_V2_Destination
         */
        private $validation;

        /**
         * 服务类
         * @var Service_Api_Destination
         */
        private $service;

        public function before()
        {
            parent::before();
            $this->result = array(
                'status' => true,//默认状态为成功
                'msg' => '操作成功',//默认的提示消息
                'data' => array()
            );
            $this->validation = Request_Api_V2_Factory::create('destination',$this->request_params);
            $this->service = new Service_Api_Destination();
        }
        public function after()
        {
            $this->send_datagrams($this->client_info['id'], $this->result, $this->client_info['secret_key']);
        }

        /**
         * 全部目的地(分级)
         */
        public function action_get_query()
        {
            try{
                $this->result['data'] = $this->service->query($this->request_params);

            } catch (Exception $e) {
                $this->result = array('status' => false, 'msg' => $e->getMessage());
            }
        }

        /**
         * 全部目的地(按字母首字母)
         */
        public function action_get_query_order_a()
        {
            try{
                $this->validation->get_query_order_a()->check();
                $this->result['data'] = $this->service->query_group_spell($this->request_params);

            } catch (Exception $e) {
                $this->result = array('status' => false, 'msg' => $e->getMessage());
            }

        }



        /**
         * 热门目的地
         */
        public function action_get_hot()
        {
            try{
                $this->validation->get_hot()->check();
                $this->result['data'] = $this->service->hot($this->request_params);

            } catch (Exception $e) {
                $this->result = array('status' => false, 'msg' => $e->getMessage());
            }

        }

        /**
         * 首页目的地栏目列表
         */
        public function action_get_index_columns()
        {
            try{
                $this->validation->get_index_columns()->check();
                $this->result['data'] = $this->service->index_columns($this->request_params);

            } catch (Exception $e) {
                $this->result = array('status' => false, 'msg' => $e->getMessage());
            }
        }

        /**
         * 目的地详情
         */
        public function action_get_destination_detail() {
            try{
                $this->validation->get_destination_detail()->check();
                $dest_id = $this->request_params['dest_id'];
                $this->result['data'] = $this->service->detail($dest_id);
            } catch (Exception $e) {
                $this->result = array('status' => false, 'msg' => $e->getMessage());
            }

        }




    }